// 引入request
import request from '../util/request.js';

const MaterialProductRequest = {
    BASE_URL : "http://localhost:8086/md",
    // 请求过程在这里开发，不在.vue文件中开发
    /**
     * 多条件分页查询dict列表
     * @param product
     * @param callBack
     */
    loadMaterialProduct(MaterialProduct, callBack){
        // 拼接url  /sys/queryByPage?xxx
        let url = this.BASE_URL + "/product/query";
        // 调用request进行请求  http://lcation
        request.get(url,MaterialProduct,callBack);
    },
    /**
     * 查询所有信息
     */
    loadMaterialProductAll(callBack){
        let url = this.BASE_URL + "/product/queryAll";
        request.get(url,null,callBack);
    },

    /**
     * 新增字典的API
     * @param product
     * @param callBack
     */
    addMaterialProduct(MaterialProduct,callBack){
        let url = this.BASE_URL + "/product/save"
        request.post(url,MaterialProduct,callBack);
    },
    /**
     * 通过id加载字典信息的API
     * @param product
     * @param callBack
     */
    getById(MaterialProductId,callBack){
        let url = this.BASE_URL + "/product/queryById?MaterialProductId=" + MaterialProductId;
        request.get(url,null,callBack);
    }
    ,
    /**
     * 修改字典信息的API
     * @param product
     * @param callBack
     */
    updateMaterialProduct(MaterialProduct,callBack){
        let url = this.BASE_URL + "/product/update";
        request.post(url,MaterialProduct,callBack);
    },
    /**
     *  删除字典的API
     * @param dictId
     * @param callBack
     */
    deleteMaterialProduct(MaterialProductId,callBack){
        request.get(this.BASE_URL + "/product/delete?MaterialProductId=" + MaterialProductId,null,callBack);
    },
    /**
     * 批量删除字典的API
     * @param dictIds
     * @param callBack
     */
    deleteMaterialProducts(MaterialProductIds,callBack){
        let url = this.BASE_URL + "/product/deletes?a=1";
        for (let i = 0; i < MaterialProductIds.length; i++){
            url += "&MaterialProductIds="+MaterialProductIds[i];
        }
        request.get(url,null,callBack);
    }
}
// 导出我们申明的dictrequest对象
export default MaterialProductRequest;